package easy;

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode() {
    }

    TreeNode(int val) {
        this.val = val;
    }

    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}

public class a965_单值二叉树 {
    public boolean isUnivalTree(TreeNode root) {
        boolean res = true;
        if (root.left != null) {
            res = root.val == root.left.val && isUnivalTree(root.left);
        }
        if (root.right != null) {
            res = root.val == root.right.val && isUnivalTree(root.right);
        }
        return res;
    }
}
